# Astra DB

> DataStax [Astra DB](https://docs.datastax.com/en/astra/home/astra.html) is a serverless vector-capable database built on Apache Cassandra® and made conveniently available
> through an easy-to-use JSON API.

### Setup

Install the following Python package:

```bash
pip install "astrapy>=0.7.1"
```

## Vector Store

```python
from langchain_astradb import AstraDBVectorStore
vector_store = AstraDBVectorStore(
    embedding=my_embedding,
    collection_name="my_store",
    api_endpoint="...",
    token="...",
)
```

Learn more in the [example notebook](/docs/integrations/vectorstores/astradb).

## Chat message history

```python
from langchain_astradb import AstraDBChatMessageHistory
message_history = AstraDBChatMessageHistory(
    session_id="test-session",
    api_endpoint="...",
    token="...",
)
```

## LLM Cache

```python
from langchain.globals import set_llm_cache
from langchain_community.cache import AstraDBCache
set_llm_cache(AstraDBCache(
    api_endpoint="...",
    token="...",
))
```

Learn more in the [example notebook](/docs/integrations/llms/llm_caching#astra-db-caches) (scroll to the Astra DB section).


## Semantic LLM Cache

```python
from langchain.globals import set_llm_cache
from langchain_community.cache import AstraDBSemanticCache
set_llm_cache(AstraDBSemanticCache(
    embedding=my_embedding,
    api_endpoint="...",
    token="...",
))
```

Learn more in the [example notebook](/docs/integrations/llms/llm_caching#astra-db-caches) (scroll to the appropriate section).

Learn more in the [example notebook](/docs/integrations/memory/astradb_chat_message_history).

## Document loader

```python
from langchain_community.document_loaders import AstraDBLoader
loader = AstraDBLoader(
    collection_name="my_collection",
    api_endpoint="...",
    token="..."
)
```

Learn more in the [example notebook](/docs/integrations/document_loaders/astradb).

## Self-querying retriever

```python
from langchain_astradb import AstraDBVectorStore
from langchain.retrievers.self_query.base import SelfQueryRetriever

vector_store = AstraDBVectorStore(
    embedding=my_embedding,
    collection_name="my_store",
    api_endpoint="...",
    token="...",
)

retriever = SelfQueryRetriever.from_llm(
    my_llm,
    vector_store,
    document_content_description,
    metadata_field_info
)
```

Learn more in the [example notebook](/docs/integrations/retrievers/self_query/astradb).

## Store

```python
from langchain_astradb import AstraDBStore
store = AstraDBStore(
    collection_name="my_kv_store",
    api_endpoint="...",
    token="..."
)
```

Learn more in the [example notebook](/docs/integrations/stores/astradb#astradbstore).

## Byte Store

```python
from langchain_astradb import AstraDBByteStore
store = AstraDBByteStore(
    collection_name="my_kv_store",
    api_endpoint="...",
    token="..."
)
```

Learn more in the [example notebook](/docs/integrations/stores/astradb#astradbbytestore).
